package com.guducat.collegeWeb.mapper;

import com.guducat.collegeWeb.entity.Permission;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 权限数据访问接口
 */
@Mapper
public interface PermissionMapper {

    /**
     * 获取所有权限
     * @return 权限列表
     */
    @Results(id = "permissionResultMap", value = {
        @Result(property = "id", column = "permission_id", id = true),
        @Result(property = "name", column = "permission_name"),
        @Result(property = "description", column = "description")
    })
    @Select("SELECT * FROM permissions")
    List<Permission> getAllPermissions();

    /**
     * 根据ID获取权限
     * @param id 权限ID
     * @return 权限对象
     */
    @Results(id = "permissionByIdResultMap", value = {
        @Result(property = "id", column = "permission_id", id = true),
        @Result(property = "name", column = "permission_name"),
        @Result(property = "description", column = "description")
    })
    @Select("SELECT * FROM permissions WHERE permission_id = #{id}")
    Permission getPermissionById(Integer id);
}
